﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WinTime.Data.Entity;

namespace WinTime.Models;
public class AppModelListDto : AppModel
{
    public int ProgressPercent;

    public int ProgressPercentWidth;


    public string DailyTime
    {
        get
        {
            // 秒
            if (TotalTime < 60)
            {
                return TotalTime + "秒";
            }
            // 分
            else if (TotalTime < 60 * 60)
            {
                var minutes = TotalTime / 60;

                return minutes + "分钟" + (TotalTime - minutes * 60) + "秒";
            }
            // 时
            else if (TotalTime < 60 * 60 * 24)
            {
                var hours = TotalTime / (60 * 60);
                return hours + "小时" + (TotalTime - hours * 60 * 60) / 60 + "分";
            }
            return TotalTime + "s";
        }
    }

    public string DisplayName
    {

        get
        {
            if (Description != null && Description != "")
            {
                return Description;
            }
            else
            {
                return Name;
            }
        }
    }

    public string Icon
    {

        get
        {
            if (IconFile.IndexOf(":") > 0)
            {
                return IconFile;
            }
            else
            {
                return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), IconFile);
            }

        }
    }

}
